package cn.gson.crmdemo.controller.product;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSONArray;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;

import cn.gson.crmdemo.model.pojo.Warehouse;
import cn.gson.crmdemo.model.service.CkService;
import cn.gson.crmdemo.model.vo.KcVo;


@Controller
public class ck {
	@Autowired
	CkService ck;
	
	@RequestMapping("ck")
	@ResponseBody
	public Map<String, Object> selectWarehouse(Integer page,Integer pageSize,
			String objects,Integer selectType) {
		Page<Object> pages = PageHelper.startPage(page,pageSize);
		JSONArray list = ck.selectWarehouse(objects,selectType);
		long total =  pages.getTotal();
		Map<String, Object> map = new HashMap<>();
		map.put("list", list);
		map.put("total", total);
		return map;
	}
	
	
		//新增
		@RequestMapping("addck")
		public String add(KcVo rkd) {	
			System.err.println(rkd);
			ck.addck(rkd);
			return "redirect:caigou?pageNum=1&pasgeSize=7&purchaseNo=";	
		}
		
		/**
		 * 查询商品和数量
		 * @return
		 */
		@RequestMapping("selectProcurementDetails")
		@ResponseBody
		public JSONArray selectProcurementDetails(int a) {
			return ck.selectProcurementDetails(a);
		}
		

}
